<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>AJAX</title>
</head>
<body>
    <p>
      <input type="button" value="发送" onclick="send();">
    </p>

    <script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
    <script>
      function send() {
          $.post(
              <!--第一个参数访问的路径-->
              "/community/alpha/ajax",

              <!--第二个参数向服务器提交的数据-->
              {
                "name":"zhangsan",
                "age": 23
              },

              <!--data是服务器传给浏览器的数据-->
              function(data) {
                console.log(typeof(data));
                console.log(data);

                data = $.parseJSON(data);
                console.log(typeof(data));
                console.log(data.code);
                console.log(data.msg);
              }
          );
      }
    </script>
</body>
</html>